<script setup>
import { userMgrUserListService } from "@/api";
import { ref, onMounted } from "vue";

defineProps({
  operName: {
    type: [Number, String],
  },
  width: {
    type: String,
  },
});

const emit = defineEmits(["update:operName"]);
const channelList = ref([]);
const getChannelList = async () => {
  const { data } = await userMgrUserListService();
  console.log(data);
  let res = data.records.map((item) => {
    let li = {
      id: item.id,
      username: item.username,
    };
    return li;
  });
  channelList.value = res;
};
onMounted(() => {
  getChannelList();
});
</script>
<template>
  <el-select
    clearable
    style="width: 190px"
    :modelValue="operName"
    @update:operName="emit('update:operName', $event)"
  >
    <el-option
      v-for="channel in channelList"
      :key="channel.id"
      :label="channel.username"
      :value="channel.username"
    ></el-option>
  </el-select>
</template>
